entities = Sketchup.active_model.entities
center_point = Geom::Point3d.new([0,0,0])
# Create a circle perpendicular to the provided vector.
normal = vector = Z_AXIS
edges = entities.add_circle(center_point, vector, 18.5.mm)      #添加一个直径37mm的圆边线
face = entities.add_face(edges)                                 #以边为界添加面
status = face.pushpull(-60.mm, true)                            #推拉-60mm形成向上的圆柱体

edges2 = entities.add_circle(center_point, vector, 11.75.mm)    #在圆柱底部画一个直径23mm的圆边线

face2 = edges2[0].common_face(edges2[1])                        #利用两边共面引用内径圆的面
status = face2.pushpull(60.mm, true)                            #推拉60mm形成圆环柱

entities.erase_entities(face2)                                  #删除内径圆的面


new_edges = entities.add_arc([0,0,0], [1,0,0], [0,0,1], 11.75.cm, 0, 180.degrees)

curve = new_edges.first.curve
points = curve.vertices.map(&:position)
points.each_with_index { |pt, i| pt.z = i * 1.5.cm/(points.length-1) }
curve.move_vertices(points)

new_edges = entities.add_arc([0,0,1.5.cm], [1,0,0], [0,0,1], 11.75.cm, 180.degrees, 360.degrees)

curve = new_edges.first.curve
points = curve.vertices.map(&:position)
points.each_with_index { |pt, i| pt.z = (i * 1.5.cm/(points.length-1)) +1.5.cm  }
curve.move_vertices(points)

radius  = 11.75.cm
pitchofscrew = 3.cm
halfpitchofscrew = pitchofscrew/2

for i in 0..19
    
    new_edges = entities.add_arc([0,0,pitchofscrew*i], [1,0,0], [0,0,1], radius, 0, 180.degrees)

    curve = new_edges.first.curve
    points = curve.vertices.map(&:position)
    points.each_with_index { |pt, j| pt.z = (j * halfpitchofscrew/(points.length-1))+ pitchofscrew*i}
    curve.move_vertices(points)

    new_edges = entities.add_arc([0,0,pitchofscrew*i+halfpitchofscrew], [1,0,0], [0,0,1], radius, 180.degrees, 360.degrees)

    curve = new_edges.first.curve
    points = curve.vertices.map(&:position)
    points.each_with_index { |pt, j| pt.z = (j * halfpitchofscrew/(points.length-1)) +halfpitchofscrew + pitchofscrew*i }
    curve.move_vertices(points)


end



for i in 0..19
    
    new_edges = entities.add_arc([0,0,pitchofscrew*i], [-1,0,0], [0,0,1], radius, 0, 180.degrees)

    curve = new_edges.first.curve
    points = curve.vertices.map(&:position)
    points.each_with_index { |pt, j| pt.z = (j * halfpitchofscrew/(points.length-1))+ pitchofscrew*i}
    curve.move_vertices(points)

    new_edges = entities.add_arc([0,0,pitchofscrew*i+halfpitchofscrew], [-1,0,0], [0,0,1], radius, 180.degrees, 360.degrees)

    curve = new_edges.first.curve
    points = curve.vertices.map(&:position)
    points.each_with_index { |pt, j| pt.z = (j * halfpitchofscrew/(points.length-1)) +halfpitchofscrew + pitchofscrew*i }
    curve.move_vertices(points)


end